***************** Replication of Franchino, Fabio, and Camilla Mariotto. “Bargaining Outcomes and Success in EU Economic Governance Reforms”. Political Science Research and Methods.

* Step 1 to reproduce Figure A7

*************   EXPLAINING COUNTRY BARGAINING SUCCESS
*************   MULTIPLE CODERS TEST SENSITIVITY ANALYSIS
* ulpoad dataset with all coders measures
do "reliability measures step1"

*Two-level linear regression of success on x1...n with random intercepts issue_id, and robust standard errors
meglm c.success c.distSQ c.distCOM c.distPRES c.distEP i.ep_rule i.ep_rule#c.distEP c.extreme c.v_power c.salience_r c.pop c.gdp_pc if vot_right==2 || issue_id: , vce(robust)

* saving betas
matrix b = get(_b)
matrix list b
svmat b, names(b)
keep b*
drop if b1==.
save betasCC.dta, replace

set seed 1234

local v = 1
while `v' <= 1000 {
* ulpoad dataset with all coders measures
do "reliability measures step1"

******  RE-ASSIGNMENT OF CODED VARIABLES
generate random = runiform()

replace success=MMsuccess if random>0.75
replace cntry_posAVE=MMcntry_posAVE if random>0.75
replace extreme=MMextreme if random>0.75
replace distCOM=MMdistCOM if random>0.75
replace distEP=MMdistEP if random>0.75
replace distSQ=MMdistSQ if random>0.75
replace pos_pres_fin=MMpos_pres_fin if random>0.75
replace distPRES=MMdistPRES if random>0.75

replace success=LCsuccess if random>0.5 & random<0.75
replace cntry_posAVE=LCcntry_posAVE if random>0.5 & random<0.75
replace extreme=LCextreme if random>0.5 & random<0.75
replace distCOM=LCdistCOM if random>0.5 & random<0.75
replace distEP=LCdistEP if random>0.5 & random<0.75
replace distSQ=LCdistSQ if random>0.5 & random<0.75
replace pos_pres_fin=LCpos_pres_fin if random>0.5 & random<0.75
replace distPRES=LCdistPRES if random>0.5 & random<0.75

********* Two-level linear regression of success on x1...n with random intercepts issue_id, and robust standard errors
meglm c.success c.distSQ c.distCOM c.distPRES c.distEP i.ep_rule i.ep_rule#c.distEP c.extreme c.v_power c.salience_r c.pop c.gdp_pc || issue_id: , vce(robust)

********* Saving betas
matrix b = get(_b)
matrix list b
svmat b, names(b)
keep b*
drop if b1==.
save bCC.dta, replace
use betasCC.dta, clear
append using bCC.dta
save betasCC.dta, replace

local v = `v' + 1
}

rename b1	distSQ
rename b2   distCOM
rename b3	distPRES
rename b4	distEP
rename b5	ep_rule_1
rename b6	ep_rule_2
rename b7	ep_rule_distEP_1b
rename b8	ep_rule_distEP_2
rename b9	extreme
rename b10	v_power
rename b11	salience_r
rename b12	pop
rename b13	gdp_pc
rename b14	cons
rename b15	var_issue_id
rename b16	var_success

save betasCC.dta, replace